package com.xy.biz.mc.domain.converter;

import com.xy.biz.mc.domain.bo.UserConnectionBO;
import com.xy.biz.mc.domain.po.UserConnectionPO;
import com.xy.biz.mc.domain.query.UserConnectionQuery;
import com.xy.biz.mc.domain.req.ListUserConnectionRequest;
import com.xy.biz.mc.domain.resp.GetUserConnectionResponse;
import com.xy.tool.util.BeanUtilsEx;

import java.util.Collection;
import java.util.List;

/**
 * 
 * 
 * @author zsp
 * @date 2021-2-25
 */
public class UserConnectionConverter {
	
	public static UserConnectionPO toPO(UserConnectionBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new UserConnectionPO(), true);
	}
	
	public static List<UserConnectionPO> toPO(Collection<UserConnectionBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new UserConnectionPO(), true);
	}
	
	public static UserConnectionBO fromPO(UserConnectionPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new UserConnectionBO());
	}
	
	public static List<UserConnectionBO> fromPO(Collection<UserConnectionPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new UserConnectionBO());
	}
	
	public static GetUserConnectionResponse toResponse(UserConnectionBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetUserConnectionResponse());
	}
	
	public static List<GetUserConnectionResponse> toResponse(Collection<UserConnectionBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetUserConnectionResponse());
	}
	
	public static UserConnectionQuery toQuery(ListUserConnectionRequest source) {
		if(null == source) {
			return null;
		}
		UserConnectionQuery target = new UserConnectionQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
